/**
 * @file 
 * This file has initial control of both the config and display interfaces.
 * 
 * @author Kenneth Dixon
 * @version 0.2
 * 
 * Licence:
 * 
 * MythBOINC is a BOINC plugin for MythTV, it allows for BOINC Client management via the MythTV interface.
 * Copyright (C) 2008  Kenneth Dixon
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/


#ifndef MAIN_CPP
#define MAIN_CPP

using namespace std;

#include "mythboinc.h"
#include "mythboincconfig.h"

#include <mythtv/mythcontext.h>
#include <mythtv/mythdbcon.h>
//#include <mythtv/lcddevice.h>
#include <mythtv/libmythui/myththemedmenu.h>


extern "C" 
{
    int mythplugin_init(const char *libversion);
    int mythplugin_run(void);
    int mythplugin_config(void);
}

/**
 * This function is automaticly run when the MythTV frontend is loaded.
 * 
 * @param libversion - Used to check for correct version
 * @returns - either succeeds to continue or fails and halts progress
 */
int mythplugin_init(const char *libversion)
{
    if (!gContext->TestPopupVersion("mythboinc", libversion, MYTH_BINARY_VERSION))
    {
        return(-1);
    }
    
    return(0);
}

/**
 * This function is run when the PLUGIN action is triggered from mythmainmenu.xml by the user.
 * It will initialise then display the main MythBOINC display page.
 */
int mythplugin_run (void)
{
    gContext->addCurrentLocation("mythboinc");

    MythBoinc* mythboinc = new MythBoinc(gContext->GetMainWindow(), "MythBOINC", "mythboinc-");
    
    mythboinc->exec();

    delete mythboinc;

    gContext->removeCurrentLocation();
	
    return(1);
}

/**
 * This function is run when the CONFIGPLUGIN action is triggered from mythmainmenu.xml by the user.
 * It will initialise then display the main MythBOINC configuration page.
 */
int mythplugin_config (void) 
{
  
    MythBoincClientsConfig *boincClientsConfig = new MythBoincClientsConfig();
    boincClientsConfig->exec();
    delete boincClientsConfig;
    return(1);
}

#endif

